#include<bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
int card[2*MAX + 100];
vector<int> a, b;
int main(){
	int n;
	cin>>n;
	int num;
	for(int i = 0; i < n; i++){
	    cin>>num;
	    card[num] = 1;
	}
	for(int i = 1; i <= 2 * n; i++){
	    if(card[i] == 1){
	        b.push_back(i);
	    }else{
	        a.push_back(i);
	    }
	}
	
	int win = 0;
	int q = 0,p;
	for(int e : a){
	    p = upper_bound(b.begin(), b.end(), e) - b.begin();
	    if(p > q){
	        win++;
	        q++;
	    }
	}
	cout<<win;
	
	return 0;
}
